package com.imoney.payment.member.generator;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.imoney.framework.base.entity.IRequest;
import com.imoney.framework.base.utils.StringUtils;
import com.imoney.payment.generator.AbstractGenerator;
import com.imoney.payment.member.domain.MemberInfo;
import com.imoney.payment.member.domain.RegCompleteRequest;
import com.imoney.payment.trade.dao.IDataCommDao;

/**
 * 类说明：<br>
 * 
 * <p>
 * 详细描述：<br>
 * 
 * </p>
 * 
 * <pre>
 * ——————————————————————————————————————————————————————————————————
 * |		修改人		|		修改时间			|		修改原因
 * ——————————————————————————————————————————————————————————————————
 * |	zengxx 曾宪新	|		2013-6-16		|	
 * ——————————————————————————————————————————————————————————————————
 * </pre>
 * 
 * @author zengxx 曾宪新(Xavier.zeng)
 * 
 *         CreateDate: 2013-6-16
 */
@Service
public class MemberInfoGenerator extends AbstractGenerator<MemberInfo> {

	@Resource
	private IDataCommDao commonDao;

	@Override
	public MemberInfo generate(IRequest request) {
		RegCompleteRequest regRequest = (RegCompleteRequest) request;
		MemberInfo memberInfo = new MemberInfo();

		memberInfo.setRealName(regRequest.getRealName());
		memberInfo.setIdCard(regRequest.getCertNo());
		if (regRequest.isCertValidForever()) {
			memberInfo.setIdCardType("-1");
		} else {
			memberInfo.setIdCardType(regRequest.getCertValidFrom() + ":"
					+ regRequest.getCertValidTo());
		}

		memberInfo.setProfession(regRequest.getProfession());
		memberInfo.setAddr(regRequest.getProv() + " " + regRequest.getCity()
				+ " " + regRequest.getCounty() + " " + regRequest.getAddress());
		if (StringUtils.isEmpty(regRequest.getSecurityQuestion())) {
			memberInfo.setSecurityKey(regRequest.getSecurityQuestion());
		} else {
			memberInfo.setSecurityKey(regRequest.getOtherSecurityQuestion());
		}
		memberInfo.setSecurityVal(regRequest.getSecurityAnswer());

		memberInfo.setEmail(regRequest.getLoginId());
		memberInfo.setTelephone(regRequest.getLoginId());

		return memberInfo;
	}

	@Override
	public List<MemberInfo> generateList(IRequest request) {

		return null;
	}

}
